package controllers;

import java.util.List;

import models.Aviso;
import play.data.validation.Valid;
import play.mvc.*;
import services.ServiceAvisos;

public class Avisos extends Controller {

    public static void index() {
        //render("Avisos/index.html");
    	List<Aviso> avisos = ServiceAvisos.listarAvisos();
        render(avisos);
    }
    
    public static void guardar(@Valid Aviso aviso){
    	if(validation.hasErrors()){
    		flash.error("Ocurrio un errror");
    		index();
    	}
    	ServiceAvisos.guardarAviso(aviso);
    	flash.success("Se guardo");
    	index();
    }

}
